#ifndef UDEVFILESYSTEM_H
#define UDEVFILESYSTEM_H

#include <jimix/Filesystem.h>
#include <jimix/File.h>
#include <jimix/Directory.h>
#include <jimix/resource.h>
#include <jimix/Process.h>

/**
  RemoteCall interface.
**/
namespace UdevFilesystem_IF
{
  const int makedev =8880;
};

/**
  Implements a filesystem for /dev.
**/
class UdevFilesystem : public Callable
{
public:
  UdevFilesystem();

  ~UdevFilesystem();

  /**
    Returns a filesystem abstraction, representing this object.
  **/
  u32int getFilesystem()
  {
    return filesystem;
  }
  
  /**
    Makes a device with name 'name', major number 'major' (a, b, c etc) and
    minor number 'minor'. If major or minor is -1, no extension is applied.
    'major' is the high 16 bits of number, 'minor' is the low 16 bits.
    The 'implementation defined' field of the file node is set as the 'minor' value.
  **/
  int makedev(char *name, bool isBlock, u32int number, u32int resource);
  
private:
  
  /**
    Our filesystem resource, for interacting with the kernel.
  **/
  u32int filesystem;
  
  /**
    We are a remote resource.
  **/
  u32int resource;
  
  /**
    Read/write methods for /dev/null.
  **/
  int nullRead(int impl, u32int offset, u32int size, u8int *buffer);
  int nullWrite(int impl, u32int offset, u32int size, u8int *buffer);
  /**
    GetItem method for /dev/tty support.
  **/
  int getItem(int impl, char *c, u32int f);
};

#endif
